//
//  REMessages.swift
//  GoGlobalis
//
//  Created by goglobails on 2018/12/29.
//  Copyright © 2018年 Chanjinger. All rights reserved.
//

import UIKit

public class REMessages {
    
    public enum PresentationStyle {
        case top
        case bottom
        case center
        case custom
    }
    
    public enum PresentationContext {
        case automatic
        case window(level: UIWindow.Level)
        case viewController(vc: UIViewController)
        case view(_: UIView)
    }
    
    public enum Duration {
        case automatic
        case forever
        case seconds(seconds: TimeInterval)
        case indefinite(delay: TimeInterval, mininum: TimeInterval)
    }
    
    public enum DimMode {
        case none
        /**
         - 'interactive': 是否点击背景隐藏视图
        */
        case gray(interactive: Bool)
        case color(color: UIColor, interactive: Bool)
        case blur(style: UIBlurEffect.Style, alpha: CGFloat, interactive: Bool)
        
        var interactive: Bool {
            switch self {
            case .none:
                return false
            case let .gray(interactive):
                return interactive
            case let .color(_, interactive):
                return interactive
            case let .blur(_, _, interactive):
                return interactive
            }
        }
        
        var model: Bool {
            switch self {
            case .gray, .color, .blur:
                return true
            case .none:
                return true
            }
        }
    }
    
    public enum Event {
        case willAppear
        case didAppear
        case willDisAppear
        case didDissAppear
    }
    
    public typealias EventListener = (Event) -> Void
    
    public struct Config {
        
        public init() {}
        
        public var presentationStyle = PresentationStyle.top
        
        public var presentationCntext = PresentationContext.automatic
        
        public var duration = Duration.automatic
        
        public var dimMode = DimMode.none
        
        public var interactiveHide = true
        
        public var prefferdStatusBarStyle: UIStatusBarStyle?
        
        public var shouldAutorotate = true
        
        public var ignoreDuplicates = true
        
        public var eventListeners: [EventListener] = []
        
        public var becomeKeyWindow: Bool?
        
        public var dimModeAccessibilityLabel: String = "dismiss"
    }
    
    public init() {}
    
    fileprivate let messageQueque = DispatchQueue(label: "re.messages", attributes: [])
    fileprivate var queque: [Pre]
}
